var __extends =
    (this && this.__extends) ||
    (function () {
      var o = function (e, t) {
        return (o =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (o, e) {
              o.__proto__ = e;
            }) ||
          function (o, e) {
            for (var t in e)
              Object.prototype.hasOwnProperty.call(e, t) && (o[t] = e[t]);
          })(e, t);
      };
      return function (e, t) {
        function s() {
          this.constructor = e;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        o(e, t),
          (e.prototype =
            null === t
              ? Object.create(t)
              : ((s.prototype = t.prototype), new s()));
      };
    })(),
  DPChooseGoodsView = (function (o) {
    function e() {
      var e = o.call(this) || this;
      return (
        (e.onLoadJiShouZhuangBeiFn = {
          caller: e,
          code: 2102,
          method: function (o) {
            if (0 == o.code) {
              (e.resList = o.list), (e.goodsArr = []);
              for (var t, s = 0; s < e.resList.length; s++)
                (t = {
                  order_Index: { text: s + 1 },
                  goods_name: e.resList[s].name,
                  goods_id: e.resList[s].id,
                }),
                  e.goodsArr.push(t);
              e.list_chooseGoods.array = e.goodsArr;
            }
          },
        }),
        (e.onLoadJiShouKuangShiFn = {
          caller: e,
          code: 2089,
          method: function (o) {
            var t = o.list;
            e.goodsArr = [];
            for (var s = 0; s < t.length; s++) {
              var d = {
                order_Index: { text: s + 1 },
                goods_name: t[s].s + "级" + t[s].name,
                goods_id: t[s].id,
              };
              e.goodsArr.push(d);
            }
            e.list_chooseGoods.array = e.goodsArr;
          },
        }),
        (e.onLoadJiShouFuJiangFn = {
          caller: e,
          code: 2090,
          method: function (o) {
            var t = o.list;
            e.goodsArr = [];
            for (var s, d = 0; d < t.length; d++)
              (s = {
                order_Index: { text: d + 1 },
                goods_name: t[d].name,
                goods_star: e.dealSuboardStar(t[d].star),
                goods_id: t[d].id,
                sort: t[d].s,
              }),
                e.goodsArr.push(s);
            e.list_chooseGoods.array = e.goodsArr;
          },
        }),
        (e.onLoadAddZBItemFn = {
          caller: e,
          code: 2092,
          method: function (o) {
            0 == o.code
              ? (ToastView.toastView("添加成功"),
                WebSocketService.send({ c: 2075, d: null }))
              : ToastView.toastView(o.msg),
              e.onChooseGoodsBackPreFn();
          },
        }),
        (e.onLoadAddKSItemFn = {
          caller: e,
          code: 2094,
          method: function (o) {
            0 == o.code
              ? (ToastView.toastView("添加成功"),
                WebSocketService.send({ c: 2075, d: null }))
              : ToastView.toastView(o.msg),
              e.onChooseGoodsBackPreFn();
          },
        }),
        (e.onLoadAddFJItemFn = {
          caller: e,
          code: 2095,
          method: function (o) {
            0 == o.code
              ? (ToastView.toastView("添加成功"),
                WebSocketService.send({ c: 2075, d: null }))
              : ToastView.toastView(o.msg),
              e.onChooseGoodsBackPreFn();
          },
        }),
        e.btn_choose_back.on(Laya.Event.CLICK, e, e.onChooseGoodsBackPreFn),
        e.tab_chooseGood.on(Laya.Event.CLICK, e, e.onTabChooseGoodsFn),
        e.list_chooseGoods.on(Laya.Event.CLICK, e, e.onChooseSelectGoodItemFn),
        (e.list_chooseGoods.renderHandler = new Laya.Handler(
          e,
          e.updateChooseGoodsItem
        )),
        (e.list_chooseGoods.vScrollBarSkin = ""),
        (e.list_chooseGoods.selectEnable = !0),
        WebSocketService.addListener(e.onLoadJiShouZhuangBeiFn),
        WebSocketService.addListener(e.onLoadJiShouKuangShiFn),
        WebSocketService.addListener(e.onLoadJiShouFuJiangFn),
        WebSocketService.addListener(e.onLoadAddZBItemFn),
        WebSocketService.addListener(e.onLoadAddKSItemFn),
        WebSocketService.addListener(e.onLoadAddFJItemFn),
        e
      );
    }
    return (
      __extends(e, o),
      (e.openView = function () {
        null == this.chooseGoodsVC && (this.chooseGoodsVC = new e()),
          (this.chooseGoodsVC.goodsType = "2"),
          (this.chooseGoodsVC.tab_chooseGood.selectedIndex = 0),
          WebSocketService.send({ c: 2102, d: { pageNum: 0 } }),
          this.chooseGoodsVC.pos(0, 40),
          Laya.stage.addChild(this.chooseGoodsVC);
      }),
      (e.prototype.updateChooseGoodsItem = function (o, e) {
        var t = o.getChildByName("goods_name");
        if ("3" == this.goodsType) {
          var s = o.dataSource.sort;
          t.color = Dictionary.colorType[s];
        } else t.color = "#FFFFFF";
      }),
      (e.prototype.dealSuboardStar = function (o) {
        var e = "";
        return o > 0 && (e = " (" + o + "星) "), e;
      }),
      (e.prototype.onTabChooseGoodsFn = function (o) {
        "item0" == o.target.name
          ? ((this.goodsType = "2"),
            WebSocketService.send({ c: 2102, d: { pageNum: 0 } }))
          : "item1" == o.target.name
          ? ((this.goodsType = "5"),
            WebSocketService.send({ c: 2089, d: { pageNum: 0 } }))
          : "item2" == o.target.name &&
            ((this.goodsType = "3"),
            WebSocketService.send({ c: 2090, d: null }));
      }),
      (e.prototype.onChooseSelectGoodItemFn = function (o) {
        if ("goods_choose_btn" == o.target.name) {
          this.goodsArr[this.list_chooseGoods.selectedIndex].goods_id,
            this.goodsArr[this.list_chooseGoods.selectedIndex].goods_name,
            this.goodsType;
          "2" == this.goodsType
            ? WebSocketService.send({
                c: 2092,
                d: {
                  id: this.goodsArr[this.list_chooseGoods.selectedIndex]
                    .goods_id,
                },
              })
            : "3" == this.goodsType
            ? WebSocketService.send({
                c: 2095,
                d: {
                  id: this.goodsArr[this.list_chooseGoods.selectedIndex]
                    .goods_id,
                },
              })
            : "5" == this.goodsType &&
              WebSocketService.send({
                c: 2094,
                d: {
                  id: this.goodsArr[this.list_chooseGoods.selectedIndex]
                    .goods_id,
                  type: 1,
                },
              });
        }
      }),
      (e.prototype.onChooseGoodsBackPreFn = function () {
        this.removeSelf();
      }),
      e
    );
  })(ui.MarketController.DPChooseGoodsViewUI);
